package com.rentplant;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.afterservice;
import com.rentplant.service.impl.afterServiceImp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Rollback(value = false)
@RunWith(SpringRunner.class)
public class afterService extends ApplicationTest{

    @Autowired
    private afterServiceImp  afterserviceimp;

    @Test
    public void test(){

        afterservice afterserviceinfo = new afterservice("s844511","[\"http://127.0.0.1:8080/image/download?name=2964e15e-c00e-420b-b0bf-5fe2050b997b.jpg\"]",
                "有对比图可以查看破损","2023-03-31 14:10:28","审核中","物品划痕2mm到5mm押金2.00%","o1677906658725"
                ,"xidnjgndfi-asdnjkcnxv");

        JSONObject afterservice = (JSONObject) JSON.toJSON(afterserviceinfo);

        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("afterServiceID","afterserviceid"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("afterServicePic","afterservicepic"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("afterServiceText","afterservicetext"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("applicationTime","applicationtime"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("serviceResult","serviceresult"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("orderIdForService","orderidforservice"));
        afterservice = (JSONObject) JSON.parse(JSON.toJSONString(afterservice).replace("userIdForService","useridforservice"));
        System.out.println(afterservice);
        boolean result = afterserviceimp.addAfterService(afterservice);
        System.out.println(result);

    }
}
